import time
import datetime
from datetime import timedelta

def get_date():
	'''传入一个time.time()的时间戳，返回  2017-09-11 15:14:33'''
	return time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))

def get_time():
	'''时间格式转化为 时间戳'''
	return time.mktime(time.strptime('20170911',"%Y%m%d"))

def date_plus1(date):
    '''子符串20180101转化为字符串20180102'''
    return (datetime.datetime.strptime(date, "%Y%m%d")+ datetime.timedelta(days=1)).strftime("%Y%m%d")

def get_everyday(begin_date,end_date):
	'''
	返回 20180105 到 20180205 之间的时间列表
	'''
	begin_date = datetime.datetime.strptime(str(begin_date), "%Y%m%d")
	end_date = datetime.datetime.strptime(str(end_date),"%Y%m%d")
	while begin_date <= end_date:
		date_str = begin_date.strftime("%Y%m%d")
		yield int(date_str)
		begin_date += datetime.timedelta(days=1)

def cal_day():
	'''计算两天的差值'''
	cur_day = datetime.datetime(2019, 1, 30)
	next_day = datetime.datetime(2019, 7, 31)
	print((next_day - cur_day).days)

def today():
	'''当天  昨天'''
	d = datetime.datetime.now()
	d += timedelta(days=-1)



